function register(){// 新用户注册
		document.getElementById("btn").disabled = true;
		$(`#tip`).html('');
		const code = $.request.queryString["code"];
		// const qrscene = $.request.queryString["millName"];
		const realName = $("#real-name").val();
		const millIid = $.request.queryString["millIid"];
		let millName = '';

		if(!realName){
			alert('【真实姓名】必须输入！');
			return;
		}

		
		// 禁用注册按钮，防止多次点击
		document.getElementById("btn").disabled = false;

		// 根据主键再次获取公司名称
		// const millUrl = getMillUrl(millIid);
		// console.log(`请求mill的url:${millUrl}`)
		// $.ajax({
		// 	url : millUrl,
	  //   type : "POST",
	  //   contentType: "application/json;charset=UTF-8",
	  //   async: false,
	  //   success : function(res) {
	  //   	if(res.code !== 1){
	  //   		alert(res.msg)
	  //   		return
	  //   	}

	  //   	millName = res.data.sid;
	  //   	console.log('根据主键查询获得的millName:' + millName)
	  //   },
	  //   error : function(e){
	  //     console.log(e.status);
	  //     console.log(e.responseText);
	  //   },
	  //   complete: function () {
	  //   }
	  // })

		
		const url = getRegisterPostUrl();
		// const params = {"code":code,"qrscene":millName,"realName":realName};
		const params = {"code":code,"millIid":millIid,"realName":realName};
		console.log('请求后台注册用户的参数是：',params)
	  $.ajax({
  		url : url,
      type : "POST",
      contentType: "application/json;charset=UTF-8",
      data:JSON.stringify(params),
      success : function(res) {
				// 后台主动抛出异常时 code = 7777
				// {code: 7777, msg: "页面授权code无效，获取用户信息失败！", data: null}
      	console.log('网页授权请求用户信息响应来的结果是：',res);
				const code = parseInt(res.code);
				if( code === 7777){
					$(`#tip`).html(res.msg);	
					return;
				}
				
      	const userInfoString = JSON.stringify(res);
      	$(`#tip`).html('已提交管理员审核，请耐心等待！');
      },
      error : function(e){
        console.log(e.status);
        console.log(e.responseText);
        $(`#tip`).html(e.responseText);
      },
      complete: function () {
        document.getElementById("btn").disabled = false;
      }
	  })

	}

	$(function(){// 页面启动即执行
		//getCode();
	});


	function getCode(){// 获取参数 code 的值
		const code = $.request.queryString["code"];
		const state = $.request.queryString["state"];	
		console.log(`code:${code},state:${state}`);
		$(`#code`).html(`code:${code}`);
		$(`#state`).html(`state:${state}`);

		const url = `https://www.xdfznh.club/wxpadbe/dev/getWebAuthorityUserInfo/${code}`;
	  $.ajax({
	      type : "GET",
	      contentType: "application/json;charset=UTF-8",
	      url : url,
	      success : function(res) {
	      	console.log('网页授权请求用户信息响应来的结果是：',res);
	      	const userInfoString = JSON.stringify(res);
	      	$(`#user-info`).html(userInfoString);
	      },
	      error : function(e){
	        console.log(e.status);
	        console.log(e.responseText);
	      }
	  })



	}


	//String openId = getOpenIdFromReqMap(map);
$.request = (function () {
	var apiMap = {}; 
	function request(queryStr) { 
			var api = {}; 
			if (apiMap[queryStr]) { return apiMap[queryStr]; } 
			api.queryString = (function () { 
					var urlParams = {}; 
					var e, 
					d = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); }, 
					q = queryStr.substring(queryStr.indexOf('?') + 1), 
					r = /([^&=]+)=?([^&]*)/g; 
					while (e = r.exec(q))     urlParams[d(e[1])] = d(e[2]);
					return urlParams; 
			})(); 
			api.getUrl = function () { 
					var url = queryStr.substring(0, queryStr.indexOf('?') + 1); 
					for (var p in api.queryString) { url += p + '=' + api.queryString[p] + "&";        } 
					if (url.lastIndexOf('&') == url.length - 1) { return url.substring(0, url.lastIndexOf('&')); } 
					return url; 
			} 
			apiMap[queryStr] = api; 
			return api; 
	} 
	$.extend(request, request(window.location.href)); 
	return request; 
})();
